import 'package:flutter/material.dart';
import 'package:xreader/pages/book_lib_page.dart';
import 'package:xreader/pages/my_info_page.dart';

class AppHome extends StatefulWidget {
  const AppHome({Key? key}) : super(key: key);

  @override
  State<AppHome> createState() => _AppHomeState();
}

class _AppHomeState extends State<AppHome> {
  final List<Widget> _bodys = [
     BookLibPage(),
    const MyInfoPage(),
  ];
  int _tabIndex = 0;


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _tabIndex,
        children: _bodys,
      ),
      bottomNavigationBar: BottomNavigationBar(
        selectedItemColor: Colors.black87,
        unselectedItemColor: Colors.black54,
        selectedFontSize: 13,
        currentIndex: _tabIndex,
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.library_books_outlined),
            activeIcon: Icon(Icons.library_books),
            label: "书库",
            backgroundColor: Colors.black87,
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.account_circle_rounded),
            activeIcon: Icon(Icons.account_circle),
            label: "我的",
            backgroundColor: Colors.black87,
          ),
        ],
        type:BottomNavigationBarType.fixed,
        onTap: (tabIndex){
          print("tabIndex===>$tabIndex");
          setState(() {
            _tabIndex = tabIndex;
          });
        },
      ),
    );
  }
}
